<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    
<script type="text/javascript">
<!--

function validateDelete() {
	var categories = $('listForm').categories;
	for (i = 0; i < cl_categories.length; i++) {
		if (categories[i].checked) {
			return confirm('Bạn có chắc muốn xóa (các) thể loại này?');
		}
	}
	alert('Bạn cần chọn ít nhất 1 thể loại.');
	return false;
}

//-->
</script>
    
<span style="color:red">${message}</span>
    
<form action="${scriptPath}" id="listForm">
<input type="hidden" name="action" value="category.list" />

<div class="toolbar">
<button name="cl_submit" value="create" type="submit">Thêm</button>
<button name="cl_submit" value="delete" type="submit" onclick="return validateDelete();">Xóa</button>
</div>

<c:forEach items="${topLevels}" var="topLevel" >
	<c:set var="category" value="${topLevel}" scope="request" />
	<jsp:include page="category.list-item.jsp"/>
</c:forEach>

<div class="toolbar">
<button onclick="location.href='${scriptPath}?action=category.create'" type="button">Thêm</button>
<button name="cl_submit" value="delete" type="button" onclick="return validateDelete();">Xóa</button>
</div>

</form>